<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
require_once ZEAI.'cache/udata.php';
if(!CRMQX('claim'))exit(noauth());
if($submitok=='add_update'){
	if(empty($list) || !is_array($list))json_exit($listtips);if(count($list)==0)json_exit(array('flag'=>0,'msg'=>'请选择您要操作的用户'));
	$today = YmdHis(ADDTIME,'Ymd');
	$SQL = getAgentSQL('aloneArea');
	//门店
	if(ifint($session_agentid) && !CRM_ADM){
		$row = $db->ROW(__TBL_CRM_AGENT__,"claimnumday","id=".$session_agentid,"name");
		if ($row){
			$claimnumday = intval($row['claimnumday']);
		}else{json_exit(array('flag'=>0,'msg'=>'门店错误，请重新登录'));}
		if($claimnumday == 0)json_exit(array('flag'=>0,'msg'=>'已关闭门店认领功能，请联系超级管理员'));
	}
	//我
	$row = $db->ROW(__TBL_CRM_HN__,"claimnumday","id=".$session_uid,"name");
	if ($row){$claimnumday_my = intval($row['claimnumday']);}
	if($claimnumday_my == 0 && !CRM_ADM)json_exit(array('flag'=>0,'msg'=>'已关闭红娘认领功能，请联系超级管理员'));
	foreach($list as $uid){
		if(ifint($session_agentid) && !CRM_ADM){//门店
			$totalnum = $db->COUNT(__TBL_CRM_CLAIM_LIST__,"agentid=".$session_agentid." AND adddate='".$today."' ");
			if($totalnum >= $claimnumday)json_exit(array('flag'=>0,'msg'=>'今天认领已达门店上限 '.$claimnumday." 人，请明天再来认领"));
		}
		if(!CRM_ADM){
			$totalnum_my = $db->COUNT(__TBL_CRM_CLAIM_LIST__,"agentid=".$session_agentid." AND adddate='".$today."' AND admid=".$session_uid);
			if($totalnum_my >= $claimnumday_my)json_exit(array('flag'=>0,'msg'=>'今天认领已达上限 '.$claimnumday_my." 人，请明天再来认领"));
		}
		$row = $db->ROW(__TBL_USER__,"nickname,agentid","admid=0 AND id=".$uid,"name");
		if ($row){
			$nickname = dataIO($row['nickname'],'out');
			$agentid  = intval($row['agentid']);
			//if($agentid==0)$db->query("UPDATE ".__TBL_USER__." SET agentid=$session_agentid,agenttitle='$session_agenttitle' WHERE agentid=0 AND hnid=0 AND hnid2=0 AND id=".$uid.$SQL);
			$SQL2 = ",agentid=$session_agentid,agenttitle='$session_agenttitle',hnid=$session_uid,hnname='$session_truename',hntime=".ADDTIME.",seatime=".ADDTIME;
			$db->query("UPDATE ".__TBL_USER__." SET admid=$session_uid,admname='$session_truename',admtime=".ADDTIME.$SQL2." WHERE id=".$uid.$SQL);
			$db->query("INSERT INTO ".__TBL_CRM_CLAIM_LIST__."  (agentid,agenttitle,admid,admname,uid,adddate) VALUES ('$session_agentid','$session_agenttitle','$session_uid','$session_truename',$uid,'$today')");
			AddLog($session_agenttitle.'红娘'.$session_truename.'->认领用户【'.$nickname.'（uid:'.$uid.'）】->成功！');
		}
	}
	json_exit(array('flag'=>1,'msg'=>'操作成功'));
}
//$totalnum = $db->COUNT(__TBL_USER__,"agentid=".$session_agentid." AND ( TO_DAYS(from_unixtime(admtime))-TO_DAYS(NOW()) = 0 ) AND admtime>0 AND admid>0 ");
$SQL_   = " (flag=1 OR flag=-2) AND admid=0 AND kind<>4 ";
$SQL    = $SQL_;
$Skeyword = trimm($Skeyword);
$Skeyword2 = trimm($Skeyword2);
if (ifmob($Skeyword)){
	$SQL .= " AND (mob=$Skeyword) ";
}elseif(ifint($Skeyword)){
	$SQL .= " AND (id=$Skeyword) ";
}elseif(!empty($Skeyword)){
	$SQL .= " AND ( ( uname LIKE '%".$Skeyword."%' ) OR ( nickname LIKE '%".$Skeyword."%' ) OR ( truename LIKE '%".$Skeyword."%' ) OR ( nickname LIKE '%".urlencode($Skeyword)."%' ) )";
}
if(ifint($Skeyword2)){
	$SQL .= " AND (admid=$Skeyword2) ";
}elseif(!empty($Skeyword2)){
	$SQL .= " AND (  admname LIKE '%".$Skeyword2."%' )";
}
if (ifint($ifmob))$SQL  .= " AND mob<>'' AND mob<>0 ";
if (ifint($ifdata))$SQL .= " AND myinfobfb>20 ";
switch ($claimflag) {
	case 1:$SQL  .= " AND (".ADDTIME." - regtime) < 259200 ";break;
	case 2:$SQL  .= " AND (".ADDTIME." - regtime) < 604800 ";break;
	case 3:$SQL  .= " AND (".ADDTIME." - regtime) < 2592000 ";break;
}
if(ifint($sex))$SQL .= " AND sex=".$sex;

//地区
$SQL .= getAgentSQL('aloneArea');
$areaid = '';
if (ifint($a1) && ifint($a2) && ifint($a3) && ifint($a4)){
	$areaid = $a1.','.$a2.','.$a3.','.$a4;
}elseif(ifint($a1) && ifint($a2) && ifint($a3)){
	$areaid = $a1.','.$a2.','.$a3;
}elseif(ifint($a1) && ifint($a2)){
	$areaid = $a1.','.$a2;
}elseif(ifint($a1)){
	$areaid = $a1;
}
$areaid2 = '';
if (ifint($h1) && ifint($h2) && ifint($h3) && ifint($h4)){
	$areaid2 = $h1.','.$h2.','.$h3.','.$h4;
}elseif(ifint($h1) && ifint($h2) && ifint($h3)){
	$areaid2 = $h1.','.$h2.','.$h3;
}elseif(ifint($h1) && ifint($h2)){
	$areaid2 = $h1.','.$h2;
}elseif(ifint($h1)){
	$areaid2 = $h1;
}
if (!empty($areaid))$SQL   .= " AND areaid LIKE '%".$areaid."%' ";
if (!empty($areaid2))$SQL  .= " AND area2id LIKE '%".$areaid2."%' ";
if (!empty($love)){
	//$love = (is_array($love))?implode(',',$love):'';
	if(is_array($love)){
		$love = implode(',',$love);
	}else{
		$getlove=explode(',',$love);
		$love = (is_array($getlove))?implode(',',$getlove):'';
	}
	$SQL .= doinsql('love',$love);
}
if (ifint($nation))$SQL    .= " AND nation=$nation ";
if (ifint($pay))$SQL       .= " AND pay>=$pay ";
if (ifint($edu))$SQL       .= " AND edu>=$edu ";
if (ifint($age1))$SQL      .= " AND ( (YEAR(CURDATE())-YEAR(birthday)-(RIGHT(CURDATE(),5)<RIGHT(birthday,5))) >= $age1 ) ";
if (ifint($age2))$SQL      .= " AND ( (YEAR(CURDATE())-YEAR(birthday)-(RIGHT(CURDATE(),5)<RIGHT(birthday,5))) <= $age2 ) ";
if (!empty($job)){
	$job = (is_array($job))?implode(',',$job):'';
	$SQL .= doinsql('job',$job);
}
if (!empty($companykind)){
	$companykind = (is_array($companykind))?implode(',',$companykind):'';
	$SQL .= doinsql('companykind',$companykind);
}
//按客户分类
if(ifint($crm_ukind))$SQL  .= " AND crm_ukind=$crm_ukind";

function doinsql($F,$V) {
	if(!empty($V)){
		$Varr=explode(',',$V);
		if (count($Varr) >= 1 && is_array($Varr)){
			$newARR=array();
			foreach ($Varr as $v2) {if(ifint($v2))$newARR[]=$v2;}
			if(count($newARR)>0){
				$list = (is_array($newARR))?implode(',',$newARR):'';	
				$ZEAI_SQL = " AND $F IN ($list) ";
			}
		}
	}
	return $ZEAI_SQL;
}
/*-------------------------------------------------------*/
switch ($sort) {
	case 'regtime0':$SORT = " ORDER BY regtime,id DESC ";break;
	case 'regtime1':$SORT = " ORDER BY regtime DESC,id DESC ";break;
	case 'endtime0':$SORT = " ORDER BY endtime,id DESC ";break;
	case 'endtime1':$SORT = " ORDER BY endtime DESC,id DESC ";break;
	default:$SORT = " ORDER BY id DESC ";break;
}

$parameter = "crm_ukind=$crm_ukind&ifmob=$ifmob&ifdata=$ifdata&sex=$sex&a1=$a1&a2=$a2&a3=$a3&a4=$a4&nation=$nation&pay=$pay&edu=$edu&h1=$h1&h2=$h2&h3=$h3&h4=$h4&age1=$age1&age2=$age2&Skeyword=$Skeyword&claimflag=$claimflag&p=$p&love=".urlencode($love)."&job=".urlencode($job)."&companykind=".urlencode($companykind); 
$searchA   = SELF."?".$parameter;

$TELSQL = ",(SELECT COUNT(*) FROM ".__TBL_TALK__." WHERE uid=U.id) AS telnum";
$MATCHSQL = ",(SELECT COUNT(*) FROM ".__TBL_CRM_MATCH__." WHERE uid=U.id) AS matchnum";
$BBSSQL   = ",(SELECT COUNT(*) FROM ".__TBL_CRM_BBS__." WHERE uid=U.id) AS bbsnum";
$QXSQL    = ",(SELECT COUNT(*) FROM ".__TBL_QIANXIAN__." WHERE senduid=U.id) AS qxnum";

$rt = $db->query("SELECT id,sex,grade,nickname,truename,photo_s,regtime,endtime,admid,hnid,hnid2,admname,mob,weixin,qq,areatitle,area2title ".$TELSQL.$MATCHSQL.$BBSSQL.$QXSQL." FROM ".__TBL_USER__." U WHERE ".$SQL.$SORT." LIMIT ".$_ADM['admLimit']);
$total = $db->num_rows($rt);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/cache/udata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/res/select4.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/cache/areadata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<link href="css/crm.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<style>
.RCW {display:inline-block}
.RCW li{width:80px}
.formline{height:10px}
.SW_checkbox,.SW_checkbox_x{display:inline-block;vertical-align:middle}
.SW_checkbox li,.SW_checkbox_x li{display:inline-block;vertical-align:middle;font-size:14px;color:#666}
.SW_checkbox li{width:100px;}
.SW_area{width:100px;padding:0 3px}
.box{padding-top:10px;padding-bottom:20px;min-width:1170px}
.throwtime{position:relative;display:inline-block;min-width:150px;margin:10px 20px 0 0;padding:5px 0;border-radius:3px;background-color:rgba(<?php echo c16_rgb($_ADM['color']);?>,.08)}
.throwtime i{position:absolute;left:-10px;top:12px;width:20px;height:20px;line-height:20px;display:inline-block;border-radius:20px;background-color:#00c;color:#fff;font-size:12px;}

.fwlist{margin-right:20px}
.fwlist span{color:#999;margin:0 5px}
.fwlist span font{color:#f00}

.jobbox{width:90%;margin:10px 0;position:relative}
.jobbox dt{float:left;min-width:32px}
.jobbox dd{float:left;width:-webkit-calc(100% - 80px)}
.jobbox #jobdd.off{height:44px;overflow:hidden}
.jobbox .jobmore{position:absolute;right:0;top:22px;color:#009688;cursor:pointer}
</style>
</head>
<body>
<div class="box">
  <div class="topsearch">
    <form name="ZEAI_CN__form1" method="get" action="<?php echo SELF; ?>">
		<?php if(empty($session_agentareaid)){?>
        地区 <script>LevelMenu4('a1|a2|a3|a4|--|<?php echo $a1; ?>|<?php echo $a2; ?>|<?php echo $a3; ?>|<?php echo $a4; ?>|areaid|areatitle','class="size2 SW_area"');</script>　
        户籍 <script>LevelMenu4('h1|h2|h3|h4|--|<?php echo $h1; ?>|<?php echo $h2; ?>|<?php echo $h3; ?>|<?php echo $a4; ?>|areaid2|areatitle2','class="size2 SW_area"');</script>　
        <div class="formline"></div>
		<?php }?>
		年龄 <script>nulltext='--';zeai_cn__CreateFormItem('select','age1','<?php echo $age1; ?>','class="size2 SW_age"',age_ARR);</script> ～ <script>nulltext='--';zeai_cn__CreateFormItem('select','age2','<?php echo $age2; ?>','class="size2 SW_age"',age_ARR);</script>　
        <script>nulltext='--民族--';zeai_cn__CreateFormItem('select','nation','<?php echo $nation; ?>','class="size2 SW_edu"',nation_ARR);</script>　
		<script>nulltext='--最低收入--';zeai_cn__CreateFormItem('select','pay','<?php echo $pay; ?>','class="size2 SW_edu"',pay_ARR);</script>　
        <script>nulltext='--最低学历--';zeai_cn__CreateFormItem('select','edu','<?php echo $edu; ?>','class="size2 SW_edu"',edu_ARR);</script>　
        <div class="jobbox">
            <dt class="textmiddle">职业</dt>
            <dd id="jobdd" <?php if (empty($job)){?>class="off" onClick="this.removeClass('off');jobmore.hide();"<?php }?>><script>zeai_cn__CreateFormItem('checkbox','job','<?php echo $job; ?>',' class=" SW_checkbox"',job_ARR);</script></dd>
            <div class="jobmore ico" id="jobmore" onClick="jobdd.removeClass('off');this.hide();">　全部职业 &#xe60b;</div>
            <div class="clear"></div>
        </div>
        <span class="textmiddle">婚况</span> <script>zeai_cn__CreateFormItem('checkbox','love','<?php echo urldecode($love); ?>','class=" SW_checkbox_x"',love_ARR);</script>　
		<span class="textmiddle">单位类型</span> <script>zeai_cn__CreateFormItem('checkbox','companykind','<?php echo $companykind; ?>','class="SW_checkbox_x"',companykind_ARR);</script>　
    	<div class="formline"></div>

        <ul id="sex_box" name="sex_box" class="size2 RCW RCWsex">
        <?php 
        $sexARR = json_decode($_UDATA['sex'],true);
        foreach ($sexARR as $V) {?>
        <input type="radio" class="radioskin" id="sex<?php echo $V['i'];?>" name="sex" value="<?php echo $V['i'];?>"<?php echo ($sex == $V['i'])?' checked':''; ?>><label for="sex<?php echo $V['i'];?>" class="radioskin-label"><i class="i1"></i><b><?php echo $V['v'];?></b></label>
        <?php }?>
        </ul>
        　<input type="checkbox" name="ifmob" id="ifmob" class="checkskin" value="1"<?php echo ($ifmob == 1)?' checked':''; ?> ><label for="ifmob" class="checkskin-label"><i class="i1"></i><b class="W50 S14">有手机</b></label>
        <input type="checkbox" name="ifdata" id="ifdata" class="checkskin" value="1"<?php echo ($ifdata == 1)?' checked':''; ?> ><label for="ifdata" class="checkskin-label"><i class="i1"></i><b class="W80 S14">资料>20%</b></label>

		<script>nulltext='--认领状态--';zeai_cn__CreateFormItem('select','claimflag','<?php echo $claimflag; ?>','class="size2"',[{i:"1",v:"今日未认领"},{i:"2",v:"本周未认领"},{i:"3",v:"本月未认领"}]);</script>　
    <span class="textmiddle">按用户</span> <input name="Skeyword" type="text" maxlength="25" class="input size2 W180" placeholder="输入姓名/昵称/UID/手机" value="<?php echo $Skeyword; ?>">　
    <button type="submit" class="btn size2 QING picmiddle"><i class="ico">&#xe6c4;</i> 开始搜索</button>
    <input type="hidden" name="crm_ukind" value="<?php echo $crm_ukind;?>">
    </form>
	</div>
    <div class="topsearch">
		<dl>
       	  <dt>客户分类</dt>
          <dd>
            <a href="javascript:;" <?php echo (empty($crm_ukind))?' class="ed"':''?> onClick="zeai.openurl('<?php echo $searchA;?>&crm_ukind=')">不限</a>
            <?php
			$crm_ukindARR = json_decode($_UDATA['crm_ukind'],true);
			if (count($crm_ukindARR) >= 1 && is_array($crm_ukindARR)){
				foreach ($crm_ukindARR as $V){
					$ukind_id    = $V['i'];
					$ukind_title = $V['v'];
					$ukindcls = ($ukind_id==$crm_ukind)?' class="ed"':'';?>
					<a href="javascript:;" <?php echo $ukindcls;?> onClick="zeai.openurl('<?php echo $searchA;?>&crm_ukind=<?php echo $ukind_id;?>&bbskind=<?php echo $bbskind;?>&ifhnid=<?php echo $ifhnid;?>')"><?php echo $ukind_title;?></a>
					<?php
				}
			}?>
          </dd>
        </dl>
    
    </div>
    <!---->
	<?php
    if ($total <= 0 ) {
        echo "<div class='nodataico'><i></i>暂无内容<br><a class='aQINGed' href='javascript:history.back(-1)'>返回</a></div>";
    } else {
        $page_skin=2;$pagemode=3;$pagesize=$_ADM['admPageSize'];require_once ZEAI.'sub/page.php';?>
        <table class="tablelist">
        <?php $sorthref = SELF."?".$parameter."&sort=";?>
        <form id="www_zeai_cn_FORM" method="get" action="<?php echo SELF; ?>">
        <tr>
        <th width="40"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
        <th width="60" align="left">头像</th>
        <th width="130" align="left">用户UID/昵称/姓名</th>
        <th width="130" align="center">注册时间<div class="sort">
        <a title="按时间升序" href="<?php echo $sorthref."regtime0";?>" <?php echo($sort == 'regtime0')?' class="ed"':''; ?>></a>
        <a title="按时间降序" href="<?php echo $sorthref."regtime1";?>" <?php echo($sort == 'regtime1')?' class="ed"':''; ?>></a>
    </div></th>
        <th width="130" align="center">最近时间<div class="sort">
        <a title="按时间升序" href="<?php echo $sorthref."endtime0";?>" <?php echo($sort == 'endtime0')?' class="ed"':''; ?>></a>
        <a title="按时间降序" href="<?php echo $sorthref."endtime1";?>" <?php echo($sort == 'endtime1')?' class="ed"':''; ?>></a>
    </div></th>
        <th width="10" align="center">&nbsp;</th>
        <th width="220" align="left">工作地区/户籍地区</th>
        <th width="120" align="left">联系方式</th>
        <th width="11" align="left">&nbsp;</th>
        <th align="center">服务历史</th>
        <th width="100" align="center">认领红娘</th>
        <th width="100" align="center">操作</th>
        <th width="22" align="center">&nbsp;</th>
        </tr>
        <?php
        for($i=1;$i<=$pagesize;$i++) {
            $rows = $db->fetch_array($rt,'name');
            if(!$rows) break;
            $id = $rows['id'];$uid = $id;
            $nickname = dataIO($rows['nickname'],'out');
            $truename = dataIO($rows['truename'],'out');
            $sex     = $rows['sex'];
            $grade   = $rows['grade'];
            $regtime = YmdHis($rows['regtime'],'YmdHi');
            $photo_s = $rows['photo_s'];
            $admid   = $rows['admid'];
            $hnid   = $rows['hnid'];
            $hnid2  = $rows['hnid2'];
            $mob    = dataIO($rows['mob'],'out');
            $weixin = dataIO($rows['weixin'],'out');
            $qq     = dataIO($rows['qq'],'out');
            $admname = dataIO($rows['admname'],'out');
            $endtime = $rows['endtime'];
            $endtime_str  = ($endtime>0)?YmdHis($endtime,'YmdHi'):'';
			
            $telnum = $rows['telnum'];
            $matchnum = $rows['matchnum'];
            $bbsnum   = $rows['bbsnum'];
            $qxnum    = $rows['qxnum'];
			$telnum_str = ($telnum>0)?'<span>外呼：<font>'.$telnum.'</font>次</span>':'';
			$matchnum_str = ($matchnum>0)?'<span>主动约见：<font>'.$matchnum.'</font>次</span>':'';
			$bbsnum_str = ($bbsnum>0)?'<span>跟进：<font>'.$bbsnum.'</font>次</span>':'';
			$qxnum_str = ($qxnum>0)?'<span>主动牵线：<font>'.$qxnum.'</font>次</span>':'';
			
            if(!empty($photo_s)){
                $photo_s_url = $_ZEAI['up2'].'/'.$photo_s;
                $photo_s_str = '<img src="'.$photo_s_url.'" class="photo_s">';
            }else{
                $photo_s_url = HOST.'/res/photo_s'.$sex.'.png';
                $photo_s_str = '<img src="'.$photo_s_url.'" class="photo_s">';
            }
            $areatitle = $rows['areatitle'];
            $area2title = $rows['area2title'];
            $title2 = trimhtml($nickname.'　/　'.$uid);
        ?>
        <tr id="tr<?php echo $id;?>">
            <td width="40" height="40"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $uid; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
            </td>
          <td width="60"><a href="javascript:;" class="qianxian" uid="<?php echo $uid;?>" title2="<?php echo urlencode($title2);?>"><?php echo $photo_s_str; ?></a></td>
          <td width="130" align="left" class="lineH150">
            
            <a href="javascript:;" class="qianxian" uid="<?php echo $uid;?>" title2="<?php echo urlencode($title2);?>">
            <?php echo uicon($sex.$grade) ?><?php echo '<font class="S12 picmiddle">'.$uid.'</font></br>';?></a>
            <font class="uleft"><?php if(!empty($nickname))echo $nickname.'</br>';if(!empty($truename))echo $truename;?></font>
            
          </td>
          <td width="130" height="60" align="center" class=" C666">
          <h5><i class="ico">&#xe634;</i> <?php echo $regtime;?></h5>
          </td>
          <td width="130" height="60" align="center" class="C666"><h5><i class="ico">&#xe634;</i> <?php echo $endtime_str;?></h5></td>
          <td width="10" height="60" align="center" class="C666">&nbsp;</td>
          <td width="220" height="60" align="left" class="lineH200"><div><?php echo (!empty($areatitle))?'<font class="C999">地区：</font>'.$areatitle:''; ?></div><div><?php echo (!empty($area2title))?'<font class="C999">户籍：</font>'.$area2title:''; ?></div></td>
          <td width="120" height="60" align="left" class="lineH200">
          
            <?php 
            if(crm_ifcontact($agentid,$admid,$hnid,$hnid2)){?>
                <font class="C999">手机：</font><?php echo $mob;?><br>
                <font class="C999">微信：</font><?php echo $weixin;?><br>
            <?php }else{?>
                <font class="C999">手机：</font>认领后可看<br>
                <font class="C999">微信：</font>认领后可看<br>
            <?php }?>
          
        </td>
          <td width="11" height="60" align="left" class="lineH200">&nbsp;</td>
        <td align="center" class="lineH150 padding10">
          <?php
		$rt2=$db->query("SELECT agentid,agenttitle,admid,admname,throwtime FROM ".__TBL_CRM_CLAIM_LIST__." WHERE adddate='0000-00-00' AND uid=".$uid." ORDER BY id DESC");
		$total2 = $db->num_rows($rt2);
		if ($total2 > 0) {
			for($i2=1;$i2<=$total2;$i2++) {
				$rows2 = $db->fetch_array($rt2,'name');
				if(!$rows2) break;
				$agentid2   = intval($rows2['agentid']);
				$agenttitle2= dataIO($rows2['agenttitle'],'out');
				$admid2     = intval($rows2['admid']);
				$admname2   = dataIO($rows2['admname'],'out');
				$throwtime2 = YmdHis($rows2['throwtime'],'YmdHis');
				$agenttitle2= (!empty($agenttitle2))?'《'.$agenttitle2.'》':'';
				$admname2   = (!empty($admname2))?$admname2.' <font class="C999">ID:'.$admid2.'</font><br>'.$throwtime2:'';
				echo '<div class="throwtime">'.$agenttitle2.$admname2.'<i>扔</i></div>';
			}
		}?>
          <div class="fwlist"><?php echo $telnum_str.$matchnum_str.$bbsnum_str.$qxnum_str;?></div>
        </td>
          <td width="100" align="center" class="lineH150"><?php if(ifint($admid)){echo $admname.'<br><font class="C999">ID:'.$admid.'</font>';}else{echo '<font class="Cf60">还未认领~~</font>';}?></td>
            <td width="100" align="center" >
            <?php 
            if(ifint($admid)){$btncls='BAI cancel';$btnstr='取消认领';}else{$btncls='add';$btnstr='<i class="ico">&#xe622;</i> 我要认领';}
            if($admid==$session_uid || $admid==0){?>
                <button type="button"  class="btn size2 <?php echo $btncls;?> " uid="<?php echo $uid;?>"><?php echo $btnstr;?></button><?php
            }else{
                if(CRM_ADM || @in_array('claim_force_cancel',$QXARR)){?>
                    <button type="button"  class="btn size2 HEI2 cancel" uid="<?php echo $uid;?>">强制取消</button>
            <?php }}?>
            </td>
            <td width="22" align="center" >&nbsp;</td>
          </tr>
        <?php } ?>
        <div class="listbottombox">
            <input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
            <input type="hidden" name="submitok" id="submitok" value="" />
            <button type="button" id="btnadd" class="btn size2 disabled action">批量认领</button>　
            <?php echo '<div class="pagebox FR">'.$pagelist.'</div>'; ?>
        </div>
        </form>
    </table>
    <?php }?>
    <!---->
</div>

<?php if ($total > 0 ) {?>
<script>
var bg = '<?php echo $_Style['list_bg']; ?>',overbg = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>',addtips='<b class="S16">确定认领此用户么？</b><br>1．认领后此用户前台个人主页将展示您的二维码，其他用户联系此用户将会加您微信，将自动更新为您所在门店<br>2．红娘帐号“<b>网站显示</b>”功能开启后用户主页才会展示您二维码等信息<br>3．认领后请尽快跟进此用户并提供服务（将自动将您设为【售前红娘】无需主管分配），财务将对认领后的红娘进行业绩考核<br>4．如要取消认领请到【认领管理】->取消认领';
zeai.listEach('.add',function(obj){
	obj.onclick = function(){
		var id = parseInt(obj.getAttribute("uid"));
		zeai.confirm(addtips,function(){
			zeai.ajax({url:'crm_claim_public'+zeai.ajxext+'submitok=add_update&list[]='+id},function(e){
				rs=zeai.jsoneval(e);
				zeai.msg(0);zeai.msg(rs.msg,{time:3});
				if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
			});
		});
	}
});
o('btnadd').onclick = function() {
	allList({
		btnobj:this,
		url:'crm_claim_public'+zeai.ajxext+'submitok=add_update',
		title:'批量认领',
		msg:'正在处理中...',
		ifjson:true,
		ifconfirm:true
	});	
}
zeai.listEach('.qianxian',function(obj){
	obj.onclick = function(){var uid = parseInt(obj.getAttribute("uid")),title2 = obj.getAttribute("title2");zeai.iframe('【'+decodeURIComponent(title2)+'】个人主页','crm_user_detail.php?t=2&iframenav=1&uid='+uid);}
});
</script>
<script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php }?>
<?php require_once 'bottomadm.php';?>